package com.gewu.pm.ui.activity.home;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.gewu.pm.R;
import com.gewu.pm.app.AppActivity;
import com.gewu.pm.bean.ManagementBean;
import com.gewu.pm.other.IntentKey;
import com.gewu.pm.ui.adapter.funds.FreezerAdapter;
import com.hjq.base.BaseAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * 冰柜下钻
 */
public class DrillingFreezerActivity extends AppActivity implements BaseAdapter.OnItemClickListener{
    private RecyclerView mRecyclerView;
    private TextView tvName;
    private FreezerAdapter mAdapter;
    private List<ManagementBean> mDataList = new ArrayList<>();

    public static void start(Context context,String name) {
        Intent intent = new Intent(context, DrillingFreezerActivity.class);
        intent.putExtra(IntentKey.NAME, name);
        context.startActivity(intent);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_drilling_freezer;
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        mRecyclerView = findViewById(R.id.rv_list);
        tvName = findViewById(R.id.tv_name);

        mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
        mAdapter = new FreezerAdapter(getContext());
        mAdapter.setOnItemClickListener(this);
        mRecyclerView.setAdapter(mAdapter);
    }
    @Override
    protected void initData() {
        tvName.setText(getString(IntentKey.NAME));

        loadData();
    }

    /**
     * 加载数据（创建测试数据）
     */
    private void loadData() {
        mDataList.clear();

        mDataList.add(new ManagementBean("终端-1876a-1——冰柜1"));
        mDataList.add(new ManagementBean("终端-1876a-1——冰柜1"));

        mAdapter.setData(mDataList);
    }

    @Override
    public void onItemClick(RecyclerView recyclerView, View itemView, int position) {

    }
}